@let empty = !(dataProvider.currentPageCount$ | async) && !(dataProvider.isLoading$ | async);

<mat-card>
  <ix-fake-progress-bar [loading]="!!(dataProvider.isLoading$ | async)"></ix-fake-progress-bar>
  <mat-toolbar-row>
    <h3>{{ 'SMB' | translate }}</h3>
    <ix-service-state-button
      [service]="service$ | async"
      [count]="+(dataProvider.currentPageCount$ | async)"
    ></ix-service-state-button>
    <div class="actions action-icon">
      <ix-search-input1
        [value]="filterString"
        [disabled]="empty"
        (search)="onListFiltered($event)"
      ></ix-search-input1>

      <a mat-button ixTest="smb-sessions" routerLink="/sharing/smb/status/sessions">
        {{ 'SMB Sessions' | translate }}
      </a>

      <ix-table-columns-selector
        [columnPreferencesKey]="'smbList'"
        [columns]="columns"
        (columnsChange)="columnsChange($event)"
      ></ix-table-columns-selector>

      <button
        *ixRequiresRoles="requiredRoles"
        mat-button
        color="primary"
        ixTest="add-smb-share"
        [ixUiSearch]="searchableElements.elements.createSmbShare"
        (click)="doAdd()"
      >
        {{ 'Add' | translate }}
      </button>
    </div>
  </mat-toolbar-row>
  <mat-card-content>
    @if (empty) {
      <ix-empty [conf]="emptyConfig"></ix-empty>
    } @else {
      <ix-table
        [ixUiSearch]="searchableElements.elements.smbList"
        [ix-table-empty]="!(dataProvider.currentPageCount$ | async)"
        [emptyConfig]="emptyService.defaultEmptyConfig(dataProvider.emptyType$ | async)"
      >
        <thead
          ix-table-head
          [columns]="columns"
          [dataProvider]="dataProvider"
        ></thead>
        <tbody
          ix-table-body
          [columns]="columns"
          [dataProvider]="dataProvider"
          [isLoading]="!!(dataProvider.isLoading$ | async)"
        ></tbody>
      </ix-table>

      <ix-table-pager [dataProvider]="dataProvider"></ix-table-pager>
    }
  </mat-card-content>
</mat-card>
